#ifndef __TREE_H
#define __TREE_H

extern "C"
{
	#include <config.h>
	#include <epan/proto.h>
}

#include <string>
#include <vector>
#include "BasicTypes.h"

using namespace std;

class Tree
{
	friend class RegExFilter;
	friend void AddRoot( proto_node * child, gpointer _this );
public:
	Tree( proto_tree & epan_tree );
	~Tree();
	string GetTreeData( TreeFormat format );

	class Node
	{
		friend void CopyChild(proto_node * child, gpointer _this );
		friend void AddRoot( proto_node * child, gpointer _this );
		friend class RegExFilter;
	public:
		Node(proto_node * epan_node, int level);
		~Node();
		string GetCaption() const {return m_caption;};
		size_t GetOffset() const {return m_offset;};
		size_t GetSize() const {return m_size;};
        ///@return true if node has children nodes or not-empty caption
        ///        and if it is not hidden.
        bool HasMeaning() const;    
		string GetXMLData();
	private:
		vector< Node* > m_children;
		string m_caption;
		size_t m_offset;
		size_t m_size;
		int m_level;
        bool m_isHidden;
        
	};
private:
	vector< Tree::Node* > m_roots;
};

string XMLString(string source);

#endif //__TREE_H